import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from hyrobot.common import CHECK_POINT, STEP

class c73301:
    name = "验证用户登录时账号/密码为空提示功能-73301"
    driver = webdriver.Firefox()

    def teststeps(self):
        STEP(1, '进入客户服务平台网页')
        self.driver.implicitly_wait(3)
        self.driver.get("http://172.17.66.19:8080/")

        STEP(2, '不输入账号和密码，点击登录')
        username = self.driver.find_element(By.NAME, "username")
        psw = self.driver.find_element(By.NAME, "password")

        username.send_keys('')
        psw.send_keys('')
        login_button = self.driver.find_element(By.CSS_SELECTOR, ".el-button")
        login_button.click()
        # self.driver.find_element(By.CSS_SELECTOR, ".el-button").click()
        got_warning_username = self.driver.find_element(By.CSS_SELECTOR,"div.el-form-item__error:nth-child(3)").text
        expected_warning = ["请输入用户名","密码不能少于六位"]
        got_warning_psw = self.driver.find_element(By.CSS_SELECTOR,"div.el-form-item__error:nth-child(4)").text
        got_warning_list = []
        got_warning_list.append(got_warning_username)
        got_warning_list.append(got_warning_psw)
        CHECK_POINT("验证是否为期待文字组合",expected_warning == got_warning_list)

        STEP(3, '不输入账号，输入任意密码，点击登录')

        username.clear()
        psw.clear()
        username.send_keys('')
        psw.send_keys('124143252')
        login_button.click()
        got_warning_username1 = self.driver.find_element(By.CSS_SELECTOR, "div.el-form-item__error:nth-child(3)").text
        expected_warning1 = "请输入用户名"
        CHECK_POINT("验证是否为期待文字组合", expected_warning1 == got_warning_username1)


        self.driver.quit()